﻿using System.Web.Mvc;

namespace Microhard.Framework.MVCHelper
{
    public static class PagetExtensions
    {
        private static IPageTitleBuilder pageTitleBuilder = new PageTitleBuilder();

        public static void AddTitleParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AddTitleParts(parts);
        }
        public static void AppendTitleParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AppendTitleParts(parts);
        }
        public static MvcHtmlString MHTitle(this HtmlHelper html, bool addDefaultTitle, params string[] parts)
        {
            html.AppendTitleParts(parts);
            return MvcHtmlString.Create(html.Encode(pageTitleBuilder.GenerateTitle(addDefaultTitle)));
        }


        public static void AddMetaDescriptionParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AddMetaDescriptionParts(parts);
        }
        public static void AppendMetaDescriptionParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AppendMetaDescriptionParts(parts);
        }
        public static MvcHtmlString MHMetaDescription(this HtmlHelper html, params string[] parts)
        {
            html.AppendMetaDescriptionParts(parts);
            return MvcHtmlString.Create(html.Encode(pageTitleBuilder.GenerateMetaDescription()));
        }


        public static void AddMetaKeywordParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AddMetaKeywordParts(parts);
        }
        public static void AppendMetaKeywordParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AppendMetaKeywordParts(parts);
        }
        public static MvcHtmlString MHMetaKeywords(this HtmlHelper html, params string[] parts)
        {
            html.AppendMetaKeywordParts(parts);
            return MvcHtmlString.Create(html.Encode(pageTitleBuilder.GenerateMetaKeywords()));
        }



        public static void AddScriptParts(this HtmlHelper html, params string[] parts)
        {
            AddScriptParts(html, ResourceLocation.Head, parts);
        }
        public static void AddScriptParts(this HtmlHelper html, ResourceLocation location, params string[] parts)
        {
            pageTitleBuilder.AddScriptParts(location, parts);
        }
        public static void AppendScriptParts(this HtmlHelper html, params string[] parts)
        {
            AppendScriptParts(html, ResourceLocation.Head, parts);
        }
        public static void AppendScriptParts(this HtmlHelper html, ResourceLocation location, params string[] parts)
        {
            pageTitleBuilder.AppendScriptParts(location, parts);
        }
        public static MvcHtmlString MHScripts(this HtmlHelper html, params string[] parts)
        {
            return MHScripts(html, ResourceLocation.Head, parts);
        }
        public static MvcHtmlString MHScripts(this HtmlHelper html, ResourceLocation location, params string[] parts)
        {
            html.AppendScriptParts(parts);
            return MvcHtmlString.Create(pageTitleBuilder.GenerateScripts(location));
        }



        public static void AddCssFileParts(this HtmlHelper html, params string[] parts)
        {
            AddCssFileParts(html, ResourceLocation.Head, parts);
        }
        public static void AddCssFileParts(this HtmlHelper html, ResourceLocation location, params string[] parts)
        {
            pageTitleBuilder.AddCssFileParts(location, parts);
        }
        public static void AppendCssFileParts(this HtmlHelper html, params string[] parts)
        {
            AppendCssFileParts(html, ResourceLocation.Head, parts);
        }
        public static void AppendCssFileParts(this HtmlHelper html, ResourceLocation location, params string[] parts)
        {
            pageTitleBuilder.AppendCssFileParts(location, parts);
        }
        public static MvcHtmlString MHCssFiles(this HtmlHelper html, params string[] parts)
        {
            return MHCssFiles(html, ResourceLocation.Head, parts);
        }
        public static MvcHtmlString MHCssFiles(this HtmlHelper html, ResourceLocation location, params string[] parts)
        {
            html.AppendCssFileParts(parts);
            return MvcHtmlString.Create(pageTitleBuilder.GenerateCssFiles(location));
        }



        public static void AddCanonicalUrlParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AddCanonicalUrlParts(parts);
        }
        public static void AppendCanonicalUrlParts(this HtmlHelper html, params string[] parts)
        {
            pageTitleBuilder.AppendCanonicalUrlParts(parts);
        }
        public static MvcHtmlString MHCanonicalUrls(this HtmlHelper html, params string[] parts)
        {
            html.AppendCanonicalUrlParts(parts);
            return MvcHtmlString.Create(pageTitleBuilder.GenerateCanonicalUrls());
        }
    }
}
